<?php
register_sidebars(2);

function unregister_categories(){unregister_widget('WP_Widget_Categories');}
add_action('widgets_init','unregister_categories');
function unregister_recent_comments(){unregister_widget('WP_Widget_Recent_Comments');}
add_action('widgets_init','unregister_recent_comments');

require(dirname(__FILE__).'/widgets/WP_Widget_Categories_Modify.php');
register_widget('WP_Widget_Categories_Modify');
require(dirname(__FILE__).'/widgets/WP_Widget_Recent_Comments_Modify.php');
register_widget('WP_Widget_Recent_Comments_Modify');

require(dirname(__FILE__).'/options.php');

function wp_pagenavi_xx() {
    //先申明两个全局变量
    global $wp_query, $wp_rewrite;
    //判断当前页面
    $wp_query->query_vars['paged'] > 1 ? $current = $wp_query->query_vars['paged'] : $current = 1;

    $pagination = array(
        'base' => @add_query_arg('paged','%#%'),
        'format' => '',
        'total' => $wp_query->max_num_pages,
        'current' => $current,
        'show_all' => false,
        'type' => 'plain',
        'end_size'=>'1',
        'mid_size'=>'3',
        'prev_text' => '上一页',
        'next_text' => '下一页'
    );

    if( $wp_rewrite->using_permalinks() )
        $pagination['base'] = user_trailingslashit( trailingslashit( remove_query_arg('s',get_pagenum_link(1) ) ) . 'page/%#%/', 'paged');
//    if( !emptyempty($wp_query->query_vars['s']) )
//        $pagination['add_args'] = array('s'=>get_query_var('s'));
    echo paginate_links($pagination);
}
add_action('widgets_init','wp_pagenavi_xx');
?>
